#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 1000005;
char str[maxn];
char initstr[maxn];
int p[maxn];
int init()
{
	initstr[0] = '$';
	int num = 1;
	int len = strlen(str);
	for(int i=0; i<len; i++)
	{
		initstr[num++] = '#';
		initstr[num++] = str[i];
	}
	initstr[num++] = '#';
	initstr[num] = '\0';
	return num;
}
int manacher(int n)
{
	int Max = 0;
	int id;
	int maxnum = -1;
	for(int i=0; i<n; i++)
	{
		if(Max > i)
			p[i] = min(p[2*id-i],Max-i);
		else p[i] = 1;
		while(initstr[i-p[i]] == initstr[i+p[i]]) p[i]++;
		if(Max < i+p[i])
		{
			Max = i+p[i];
			id = i;
		}
		maxnum = max(p[i], maxnum);
	}
	return maxnum;
}
int main()
{
	while(scanf("%s",str)!=EOF)
	{
	    int len = strlen(str);
	    for(int i = len;i < len * 2;i ++){
            str[i] = str[i - len];
	    }
		int n = init();
		int res = manacher(n)-1;
        if(res > len){
            res = len;
        }
		printf("%d\n",res);
	}
	return 0;
}
